﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="OrderUsingsBulbItem.cs" company="StyleCop for ReSharper Development Team">
//   Copyright (c) StyleCop for ReSharper Development Team. All rights reserved.
// </copyright>
// <summary>
//   Defines the OrderUsingsBulbItem type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace StyleCop.For.ReSharper.BulbItems.Ordering
{
    #region Using Directives

    using JetBrains.ProjectModel;
    using JetBrains.TextControl;

    using StyleCop.For.ReSharper.BulbItems.Framework;
    using StyleCop.For.ReSharper.CodeCleanup.Options;
    using StyleCop.For.ReSharper.CodeCleanup.Rules;
    using StyleCop.For.ReSharper.CodeCleanup.Styles;
    using StyleCop.For.ReSharper.Core;

    #endregion

    /// <summary>
    /// BulbItem - OrderUsingsBulbItem : Qualifies all usings, the orders them, groups them and removes duplicates.
    /// </summary>
    public class OrderUsingsBulbItem : V5BulbItemImpl
    {
        public override void ExecuteTransactionInner(ISolution solution, ITextControl textControl)
        {
            var file = Utils.GetCSharpFile(solution, textControl);

            var options = new OrderingOptions { AlphabeticalUsingDirectives = AlphabeticalUsingsStyle.Alphabetical, ExpandUsingDirectives = ExpandUsingsStyle.FullyQualify };

            // Fixes SA1208, SA1209, SA1210, SA1211
            new OrderingRules().Execute(options, file);
        }
    }
}